local function main (userOb, msgData)
    local player_dbase = userOb:query("player_dbase")
    if not player_dbase then
        local result = {}
        result.error = 1
        userOb:send_packet("MSGS2CGrantGiftOpen", result)
        return
    end

    local common_config = IMPORT_D:query("common")
    if not common_config then
        local result = {}
        result.error = 2
        userOb:send_packet("MSGS2CGrantGiftOpen", result)
        return
    end

    local empower = common_config.empower
    if type(empower) ~= "table" then
        local result = {}
        result.error = 3
        userOb:send_packet("MSGS2CGrantGiftOpen", result)
        return
    end

    if userOb:query("player_grant") then
        local result = {}
        result.error = 4
        userOb:send_packet("MSGS2CGrantGiftOpen", result)
        return
    end

    userOb:set("player_grant", os.time())

    local reward = {}
    for item_id, item_count in pairs(empower) do
        userOb:add_currency(item_id, item_count)
        table.insert(reward, { propId = item_id, propCount = item_count, })
    end

    local result = {}
    result.error = 0
    result.reward = reward
    userOb:send_packet("MSGS2CGrantGiftOpen", result)

    ---! 记录授权日志
    LOG_D:write_login_log("grant_user", 1, userOb)
end

COMMAND_D:register_command("MSGC2SGrantGiftOpen", GameCmdType.NONE, main)
